package com.nd.android.u.ui.longClickMenu.contact;

import android.content.Context;

import com.nd.android.u.business.db.dao.RecentContactRecords;
import com.nd.android.u.controller.bean.contact.RecentContactItem;
import com.nd.android.u.controller.bean.event.UnreadCountChangedEvent;
import com.nd.android.u.controller.bean.event.UpdateRecentContactListEvent;
import com.nd.android.u.controller.innerInterface.IContactLongClickMenu;
import com.nd.android.u.ui.R;
import com.product.android.business.ApplicationVariable;

import de.greenrobot.event.EventBus;

/**
 * 最近联系人界面长按菜单：从联系人中移除
 * <br>Created 2014-8-12 上午10:49:11
 * @version  
 * @author   cb		
 * @see 	 
 */
public class ContactLongClickMenu_Del implements IContactLongClickMenu {

	@Override
	public String getLabel() {
		return ApplicationVariable.INSTANCE.applicationContext.getString(R.string.context_menu_item_remove_contact);
	}

	@Override
	public void onClick(Context context,RecentContactItem item) {
		RecentContactRecords.INSTANCE.deleteItem(item);
		EventBus eb = EventBus.getDefault();
		eb.post(new UnreadCountChangedEvent());
		if (RecentContactRecords.INSTANCE.isEmpty()) {
			eb.post(new UpdateRecentContactListEvent());
		}
	}

	@Override
	public boolean isEnable(RecentContactItem item) {
		//该功能对所有联系人都可用
		return true;
	}
}
